<template>
  <div class="search">
    <no-data :msg="msg"></no-data>
    <div v-if="articleList.length!==0">
      <list-item :articleList="articleList" :articleTotal="articleTotal"></list-item>
    </div>
    <div v-if="articleList.length===0">
      <no-data msg="没有搜到..."></no-data>
    </div>
  </div>
</template>

<script>
import noData from 'base/NoData'
import listItem from 'base/articleList/list.vue'
export default {
  name: 'about',
  data() {
    return {
      articleList: [],
      articleTotal: 100
    }
  },
  components: {
    noData,
    listItem
  },
  computed: {
    msg() {
      return `有关 "${this.$route.query.keyword}" 的文章`
    }
  },
  created() {
    if (this.$route.query.keyword) {
      this.getSearch()
    }
  },
  methods: {
    getSearch() {
      this.$store.dispatch('GetArticleList', {
        keyword: this.$route.query.keyword,
        pageindex: 1,
        pagesize: 1000,
        type: 'search'
      }).then((res) => {
        this.articleList = res.list
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.search {}
</style>
